package com.syiti.dev.example.service.consumer.app.modular.user.controller;

import com.syiti.dev.example.service.consumer.app.modular.user.convert.UserConvert;
import com.syiti.dev.example.service.consumer.app.modular.user.dao.dataobject.UserDO;
import com.syiti.dev.example.service.consumer.app.modular.user.service.UserService;
import com.syiti.dev.example.service.consumer.app.modular.user.vo.UserVO;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 示例接口
 *
 * @author caiti
 * @since 2021-05-10
 */
@RestController
@RequestMapping("/user")
@RequiredArgsConstructor
public class UserController {

    private final UserService userService;
    private final UserConvert userConvert;

    @GetMapping("/login-user")
    public UserVO loginUser() {
        UserDO userDO = userService.getUser();
        return userConvert.doConvertVO(userDO);
    }

    @GetMapping("/list")
    public List<UserVO> list() {
        List<UserDO> userListDO = userService.getUserList();
        return userConvert.doListConvertListVO(userListDO);
    }

}
